using System.Data;

namespace Yama.MVC.Dao.Connections
{
    ///<summary>
    /// Contract for class, which handles opening, commiting, rolling back and disposing of transactions.
    /// 
    /// This class is used by Yama.MVC.Monorail.Extensions.TransactionManagementExtension
    /// automatically opens and closes transactions during a Monorail http request 
    ///</summary>
    public interface ITransactionHandler
    {
        ///<summary>
        /// Disposes of transaction
        ///</summary>
        void DisposeOfTransaction();

        /// <summary>
        /// Commits transaction
        /// </summary>
        void CommitTransaction();

        /// <summary>
        /// Rolls back transaction
        /// </summary>
        void RollbackTransaction();

        /// <summary>
        /// Returns true if a transaction is active
        /// </summary>
        bool IsTransactionActive { get; }

        /// <summary>
        /// Opens a new transaction with the selected <see cref="IsolationLevel"/>
        /// </summary>
        void BeginTransaction(IsolationLevel isolationLevel);
    }
}